$(document).ready(function () {
    //点击注册跳转到注册页面
    $("#register").click(function () {

        $.ajax({
            type: "get",
            url: "/user/registerPage",
            data: {},
            success: function () {

            },
            error: function () {

            }
        });
    });
    var isFree = false;
    //点击登录按钮，提交邮箱，密码信息
    $("input[type=checkbox]").click(function () {
        if ($(this).is(":checked")) {
           isFree =true;
        }
    });
    $("#btn").click(function () {
        var uEmail = $("#email").val();
        var uPwd = $("#password").val();

        // var freeLogin = $("input[name='freeLogin']:checked").val();
        // if($("#freeLogin").is(":checked")){
        //     alert($("#freeLogin").val());
        // }

        if (uEmail == "") {
            alert("昵称不能为空");
            return false;
        } else if (uPwd == "") {
            alert("密码不能为空");
            return false;
        } else {
            $.ajax({
                type: "post",
                url: "/user/checkLogin",
                data: {
                    uEmail: uEmail,
                    uPwd: uPwd,
                  freeLogin: isFree
                },
                success: function (data) {
                    console.log(data);

                    if (data.success==true) {
                        if (data.data == 0) {
                            alert(data.msg);
                            window.location.href = "/user/index";
                        } else if (data.data == 1) {
                            alert(data.msg);
                            window.location.href = "/user/back";
                        }
                    } else {
                        alert(data.msg);
                    }
                },
                error: function () {

                }
            });
        }
    });
    $(".findPassword").click(function () {
        $(".sign-input1").slideToggle();
    });

    $("#btnSend").click(function () {
        var email = $("#emailSend").val();
        alert(email);
        $.ajax({
            type: "post",
            url: "/user/findPwd",
            data: {
                email:email
            },
            success: function (data) {
                alert(data.msg)
            },
            error: function () {

            }
        });
    });
});